package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 19182
 * Date: 2025-08-15
 * Time: 11:21
 */
public class demo13 {
    private static int count = 0;
    public void add(){
        synchronized (this){
            count++;
        }
    }
    public static void main(String[] args) throws InterruptedException {
        demo13 demo13 = new demo13();
        Thread t1 = new Thread(()->{
             for(int i = 0; i < 10000; i++){
                 demo13.add();
             }
        });
        demo13 demo131 = new demo13();
        Thread t2 = new Thread(()->{
            for(int i = 0; i < 10000; i++){
                demo131.add();
            }
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();;
        System.out.println(count);
    }
}
